#ifndef _CMD_CORE_UTILS_H_
#define _CMD_CORE_UTILS_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include <string.h>

#define MAX(a,b) ( ((a)>(b)) ? (a):(b) )
#define MIN(a,b) ( ((a)>(b)) ? (b):(a) )

#define STR_SUCCESS	"success\n"
#define STR_FAIL	"fail\n"
#define STR_ON                 "on"
#define STR_OFF                "off"

char *trimstr(char *string);
char *trimleftblank(char *string);
void trimrightblank(char *string);

char *trim_left_delimiter(char *string, char delimiter);
char *get_delimited_string(char *string, char delim, char *ret_segment);
int get_lenth_to_delimiter(const char *string, char delimiter);
char *get_delimited_string_segment(char *string, char delimiter);
char *jump_to_next_delimited_segment(char *string, char delimiter);
void realse_delimited_string_segment(char *segment);

int parse_int_value(char *string);
int8_t parse_on_off(char *string);

int return_success_default(char *ret_buf, size_t ret_max_len);
int return_fail_default(char *ret_buf, size_t ret_max_len);

#ifdef __cplusplus
}
#endif

#endif
